
<?php	
	
	class coupon extends database
	{
		var $connection = '';	

		function coupon()
		{
			parent::database();
		}
	
		function GetListPaging()
		{						
			$this->setQuery("set names utf8");
			$this->query();
			return $sql = "Select * from vnf_coupon";			
			//return $pager;
			//$rs = $pager->paginate();
	//Loop through the result set
				
			/*$this->setQuery($sql);
			$value = $this->loadAllRow();
			return $value;*/
		}
		
		function GetList()
		{						
			$this->setQuery("set names utf8");
			$this->query();			
			$sql = "SELECT * from vnf_coupon ";			
			$this->setQuery($sql);
			$value = $this->loadAllRow();
			return $value;
		}
        
        function AddCoupon($CouponCode, $CouponTitle, $CouponType, $Note, $Value)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "Insert into vnf_coupon(`CouponCode`, `CouponTitle`, `CouponType`, `Note`, `Value`) 
            values('".$CouponCode."', '".$CouponTitle."', '".$CouponType."', '".$Note."', '".$Value."')";
            //echo $sql;
			$this->setQuery($sql);
			$this->query();
		}
		
		function UpdateCoupon($CouponCode, $CouponTitle, $CouponType, $Note, $Value, $id)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "";
			$sql = "Update vnf_coupon set `CouponCode` =  '".$CouponCode."', 
            `CouponTitle` = '".$CouponTitle."', `CouponType` = '".$CouponType."', 
            `Note` = '".$Note."',`Value` = '".$Value."'";
			$sql .= " where CouponID=".$id;	
            //echo $sql;		
			$this->setQuery($sql);
			$this->query();
		}
		
		function GetOneCoupon($id)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "Select * from vnf_coupon where CouponID=".$id."";
			$this->setQuery($sql);
			$row = $this->loadOneRow();
			return $row;
		}
		
		function DeleteCoupon($id)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "";
			$sql = "Delete from vnf_coupon ";
			$sql .= " where CouponID=".$id;			
			
			$this->setQuery($sql);
			$this->query();
		}
	
		
	}
?>